import requests
import bs4

def downloadUrl(url):
    res = requests.get(url)
    res.raise_for_status()
    print(type(res))
    if res.status_code == requests.codes.ok:
        print(len(res.text))
        playfile = open("mydata", 'wb')
        for chunk in res.iter_content(100000):
            playfile.write(chunk)
        playfile.close()




downloadUrl("https://www.baidu.com")